home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 362 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: alterdial.uu.net!dweaver
  2. From: dweaver@nondum.cleaf.com (David Weaver)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Strange (to me) notation - little help?
  5. Date: 4 Jan 1996 03:57:55 GMT
  6. Message-ID: <4cfj83$1a5@alterdial.UU.NET>
  7. References: <30EB32AC.2836@sierra.net>
  8. Reply-To: dweaver@clover.cleaf.com
  9. NNTP-Posting-Host: dial3txk.cleaf.com
  10.  
  11. In article <30EB32AC.2836@sierra.net>, "Tyler G. Colwell" <snowbull@sierra.net> writes:
  12.  
  13. |>  SimpleCat::SimpleCat(int age, int weight):
  14. |>  itsAge(age), itsWeight(weight) {}
  15. |> ***********************************************
  16. |> 
  17. |> Wow, those last two lines are dumbfounding.  What is the colon at the end
  18. |> of that one line for, and what's up 
  19. |> with using members itsAge and itsWeight as functions in the last line, 
  20. |> and howcome none of them are inside the 
  21. |> braces?
  22.  
  23. The colon at the end of the line introduces a member initialization list
  24. The member initialization list follows the colon.  The members itsAge
  25. and itsWeight are not exactly being used as functions; they are being
  26. initialized.  The braces are empty because, for this particular class
  27. constructor, there is no assignment phase following the initialization phase.
  28.  
  29. It seems odd that a primer would introduce that syntax without any prior
  30. explination.  Look in your index for "member initialization list" to see
  31. if there's an explination in the book.
  32.  
  33.